package phoside.util;

import java.io.File;

import java.util.ArrayList;

import javax.swing.filechooser.FileFilter;

public class FileExtensionsFilter extends FileFilter {
	private ArrayList<String> acceptedExtensions;
	private String description;
	
	public FileExtensionsFilter(ArrayList<String> exts, String desc) {
		acceptedExtensions = exts;
		description = desc;
	}
	
	public boolean accept(File arg0) {
		if (arg0.isDirectory()) return true;
		String ext = FilePathParser.getExt(arg0.getName());
		if (ext==null) return false;
		int n = acceptedExtensions.size();
		for (int i=0; i<n; i++) {
			if (ext.compareToIgnoreCase((String)acceptedExtensions.get(i))==0) {
				return true;
			}
		}
		return false;
	}

	public String getDescription() {
		return description;
	}

	
}
